import Vuex from 'vuex';
import Vue from 'vue';
import {queryUserCfg} from "../service";
import {getCfgValue, getCfgList} from "../../components/Cfg/LayoutCfg";

Vue.use(Vuex);

const state = {
    userInfo: {
        cfgs: [],
        resTree: [],
        user: {},
    }
};

const mutations = {
    async initUserCfg(state) {
        debugger
        let res = await queryUserCfg();
        state.userInfo = res.data;
        document.title = getCfgValue(state.userInfo.cfgs, 'application.title');
        //window.changeUserCfg = this.changeUserCfg.bind(this);
    }
};

const modules = {};
const actions = {};

export default new Vuex.Store({
    state,
    modules,
    mutations,
    actions
})
